package com.cx.service.impl;


import com.cx.pojo.Comment;
import com.cx.pojo.Responses;
import com.cx.repository.CommentRepository;
import net.sf.json.JSONObject;
import com.cx.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
//直接按时间和文章id还有评论id检索就可以了，不必设置唯一自增主键

@Service
public class CommentServiceImpl implements CommentService {
    @Autowired
    CommentRepository commentRepository;

    @Override
    public List<JSONObject> findAllComments() {
        return commentRepository.findAllComments();
    }

    @Override
    public List<Comment> findByPostId(String id) {
        return commentRepository.findByPostId(id);
    }

    @Override
    public int insertComment(Comment comment) {
        return commentRepository.insertComment(comment);
    }

    @Override
    public int deleteComment(String id) {
        return commentRepository.deleteComment(id);
    }


    @Override
    public int addResponse(String id , Responses responses) {

        return commentRepository.addResponse(id,responses);
    }

    @Override
    public int deleteResponse(String id, String responses_id) {
        return commentRepository.deleteResponse(id,responses_id);
    }


}
